package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("coupons/returncoupon")
public @caption("回归优惠券") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("tb_return_coupon") class TbReturnCoupon implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
		
	
		
	private @caption("编号") @column("tbrc_id")    @primary  @notnull  @note("  ") Long tbrcId;// 主键 非空     
			
 			
 			
 		
	
		
	private @caption("会员") @column("tbrc_member")      @note("  ") Long tbrcMember;//     
			
 			
 			
 		
	
		
	private @caption("邀请人") @column("tbrc_yq")      @note("  ") Long tbrcYq;//     
			
 			
 			
 		
	
		
	private @caption("品牌") @column("tbrc_brand")      @note("  ") Long tbrcBrand;//     
			
 			
 			
 		
	
		
	private @caption("优惠券") @column("tbrc_coupon")      @note("  ") Long tbrcCoupon;//     
			
 			
 			
 		
	
		
	private @caption("领取情况") @column("tbrc_get")      @note(" 1:未领取 2:已领取  ") Short tbrcGet;// 1:未领取 2:已领取     
			
 			
 			
 		
	
		
	private @caption("添加时间") @column("tbrc_add_time")      @note("  ") Date tbrcAddTime;//     
			
 			
 			
 		
	
	 
	//默认构造函数
	public TbReturnCoupon(){ 
	
	}
	
	//主键构造函数
	public TbReturnCoupon(Long id){
		this.tbrcId = id;
	}
	
	/**所有字段构造函数 
	 TbReturnCoupon(
	 	Utils.getLong("member")//会员
	 	,Utils.getLong("yq")//邀请人
	 	,Utils.getLong("brand")//品牌
	 	,Utils.getLong("coupon")//优惠券
	 	,Utils.getShort("get")//领取情况
	 	,Utils.getDate("addTime")//添加时间
	 )
	**/
	public TbReturnCoupon(Long tbrcMember,Long tbrcYq,Long tbrcBrand,Long tbrcCoupon,Short tbrcGet,Date tbrcAddTime){
		
			
			
		this.tbrcMember=tbrcMember;
		
			
		this.tbrcYq=tbrcYq;
		
			
		this.tbrcBrand=tbrcBrand;
		
			
		this.tbrcCoupon=tbrcCoupon;
		
			
		this.tbrcGet=tbrcGet;
		
			
		this.tbrcAddTime=tbrcAddTime;
		
	}
	
	//设置非空字段
	public TbReturnCoupon setNotNull(){
		
			
			
			
			
			
			
			
		return this;
	}
	
	
		
	/** 编号 [非空]       **/
	public TbReturnCoupon tbrcId(Long tbrcId){
		this.tbrcId = tbrcId;
		this.setSeted(F.tbrcId);
		return this;
	}
	
		
	/** 会员        **/
	public TbReturnCoupon tbrcMember(Long tbrcMember){
		this.tbrcMember = tbrcMember;
		this.setSeted(F.tbrcMember);
		return this;
	}
	
		
	/** 邀请人        **/
	public TbReturnCoupon tbrcYq(Long tbrcYq){
		this.tbrcYq = tbrcYq;
		this.setSeted(F.tbrcYq);
		return this;
	}
	
		
	/** 品牌        **/
	public TbReturnCoupon tbrcBrand(Long tbrcBrand){
		this.tbrcBrand = tbrcBrand;
		this.setSeted(F.tbrcBrand);
		return this;
	}
	
		
	/** 优惠券        **/
	public TbReturnCoupon tbrcCoupon(Long tbrcCoupon){
		this.tbrcCoupon = tbrcCoupon;
		this.setSeted(F.tbrcCoupon);
		return this;
	}
	
		
	/** 领取情况    1:未领取 2:已领取     **/
	public TbReturnCoupon tbrcGet(Short tbrcGet){
		this.tbrcGet = tbrcGet;
		this.setSeted(F.tbrcGet);
		return this;
	}
	
		
	/** 添加时间        **/
	public TbReturnCoupon tbrcAddTime(Date tbrcAddTime){
		this.tbrcAddTime = tbrcAddTime;
		this.setSeted(F.tbrcAddTime);
		return this;
	}
	
	
	
	/**
	* 克隆对象
	**/
	public TbReturnCoupon clone(){
		TbReturnCoupon clone = new TbReturnCoupon();
		
			
			
		clone.tbrcMember=this.tbrcMember;
		
			
		clone.tbrcYq=this.tbrcYq;
		
			
		clone.tbrcBrand=this.tbrcBrand;
		
			
		clone.tbrcCoupon=this.tbrcCoupon;
		
			
		clone.tbrcGet=this.tbrcGet;
		
			
		clone.tbrcAddTime=this.tbrcAddTime;
		
		return clone;
	}
	
	
	
	
	
	/**
	 * 根据ID取回归优惠券
	 * @param id
	 * @return
	 */
	public static @api TbReturnCoupon get(Long id){		
		return getTbReturnCouponById(id);
	}
	
	
	/**
	 * 设置ID
	 * @param id
	 * @return
	 */
	public void setId(Long id){		
		this.tbrcId = id;
	}
	
	
	/**
	 * 获取所有回归优惠券
	 * @return
	 */
	public static @api List<TbReturnCoupon> list(Map params,Integer size){
		return getTbReturnCouponList(params,size);
	}
	/**
	 * 获取回归优惠券分页
	 * @return
	 */
	public static @api Page<TbReturnCoupon> page(Integer page,Integer size,Map params){
		return getTbReturnCouponPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取回归优惠券
	 * @param params
	 * @return
	 */
	public static @api TbReturnCoupon Get(Map params){
		return getTbReturnCoupon(params);
	}
	/**
	 * 获取回归优惠券数
	 * @return
	 */
	public static @api Long count(Map params){
		return getTbReturnCouponCount(params);
	}
	/**
	 * 获取回归优惠券数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getTbReturnCouponEval(eval,params);
	}
	
	
	/**
	 * 获取回归优惠券图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getTbReturnCouponStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取回归优惠券图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getTbReturnCouponStats(params,sumKey,groupKey,dateType);
	}
	
	
	/**
	 * 根据ID取回归优惠券
	 * @param id
	 * @return
	 */
	public static @api TbReturnCoupon getTbReturnCouponById(Long id){		
		return getTbReturnCouponDao().getTbReturnCouponById(id);
	}
	
	
	/**
	 * 获取id
	 * @return
	 */
	public Long getId(){
		return this.tbrcId;
	}
	
	
	
	/**
	 * 根据ID取回归优惠券的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			
			return null;
			
		}
		String value = null;
		
		value = Cache.getValue(TbReturnCoupon.class, id);
				
		if(value==null){
			TbReturnCoupon tbReturnCoupon = get(id);
			if(tbReturnCoupon!=null){
				String strValue = tbReturnCoupon.getTbrcId$();
				
				
				Cache.setValue(TbReturnCoupon.class, id ,strValue);
				
				value = strValue;
			}else{
				
				Cache.setValue(TbReturnCoupon.class, id ,"{"+id+"}",30);
				
				value = "{"+id+"}";
			}
		}
		
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getTbrcId$();
		
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询回归优惠券对象
	 * @return
	 */
	public static @api TbReturnCoupon find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("tbrcId", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return TbReturnCoupon.getTbReturnCoupon(params);
	}
	
	
	/**
	 * 根据关键字查询回归优惠券
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","tbrc_id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("tbrcId", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		
		
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<TbReturnCoupon> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(TbReturnCoupon tbReturnCoupon:list){
			Map map = new HashMap();
			map.put("key",tbReturnCoupon.getTbrcId().toString());
			map.put("value", Utils.js(tbReturnCoupon.getKeyValue()));
			if(bObject==true)
				map.put("object",tbReturnCoupon);
			result.add(map);
		}
		
		
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有回归优惠券
	 * @return
	 */
	public static @api List<TbReturnCoupon> getTbReturnCouponList(Map params,Integer size){
		return getTbReturnCouponDao().getTbReturnCouponList(params,0,size);
	}
	
	/**
	 * 获取回归优惠券分页
	 * @return
	 */
	public static @api Page<TbReturnCoupon> getTbReturnCouponPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getTbReturnCouponDao().getTbReturnCouponPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取回归优惠券
	 * @param params
	 * @return
	 */
	public static @api TbReturnCoupon getTbReturnCoupon(Map params){
		return getTbReturnCouponDao().getTbReturnCoupon(params);
	}
	
	/**
	 * 保存一个回归优惠券
	 * @param tbReturnCoupon
	 * @return
	 */
	public static @api TbReturnCoupon saveTbReturnCoupon(TbReturnCoupon tbReturnCoupon){
		return getTbReturnCouponDao().saveTbReturnCoupon(tbReturnCoupon);
	}
	
	/**
	 * 根据条件更新回归优惠券
	 * @param values
	 * @param params
	 */
	public static @api int updateTbReturnCouponByConfirm(Map values, Map params){
		return getTbReturnCouponDao().updateTbReturnCouponByConfirm(values,params);
	}
	
	/**
	 * 修改一个回归优惠券
	 * @param tbReturnCoupon
	 * @return
	 */
	public static @api int updateTbReturnCoupon(TbReturnCoupon tbReturnCoupon){
		return getTbReturnCouponDao().updateTbReturnCoupon(tbReturnCoupon);
	}
	
	/**
	 * 更新回归优惠券非空字段
	 * @param tbReturnCoupon
	 */
	public static @api int updateTbReturnCoupon$NotNull(TbReturnCoupon tbReturnCoupon){
		return getTbReturnCouponDao().updateTbReturnCoupon$NotNull(tbReturnCoupon);
	}
	
	/**
	 * 获取回归优惠券数
	 * @return
	 */
	public static @api Long getTbReturnCouponCount(Map params){
		return getTbReturnCouponDao().getTbReturnCouponCount(params);
	}
		
		
	/**
	 * 获取回归优惠券自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getTbReturnCouponEval(String eval,Map params){
		return getTbReturnCouponDao().getTbReturnCouponEval(eval,params);
	}
	
	
	/**
	 * 获取回归优惠券图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getTbReturnCouponStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getTbReturnCouponDao().getTbReturnCouponStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = TbReturnCoupon.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(TbReturnCoupon.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateTbReturnCoupon(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getTbReturnCouponDao().updateTbReturnCouponByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteTbReturnCoupon(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getTbReturnCouponDao().deleteTbReturnCouponByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		
		getTbReturnCouponDao().deleteTbReturnCouponById(id);
		
	}
	
	
	/**
	 * 保存回归优惠券对象
	 * @param params
	 * @return
	 */
	public TbReturnCoupon save(){
		if(this.getTbrcId()!=null)
			getTbReturnCouponDao().updateTbReturnCoupon(this);
		else
			return getTbReturnCouponDao().saveTbReturnCoupon(this);
		return this;
	}
	
	
	/**
	 * 更新回归优惠券对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getTbReturnCouponDao().updateTbReturnCoupon$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
		
			getTbReturnCouponDao().deleteTbReturnCouponById(this.getTbrcId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getTbReturnCouponDao().executeTransaction(function);
	}

	
	
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getTbrcId(){
		
		if(this.tbrcId!=null){
			return this.tbrcId;
		}
		
		return this.tbrcId;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getTbrcId$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getTbrcId());
	 
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setTbrcId$(String strValue){
		if(Utils.empty(strValue)){
			this.tbrcId=null;
			return;
		}
	
	
	 	this.tbrcId=Utils.parseLong(strValue);
	 
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setTbrcId(Long tbrcId){
		this.tbrcId = tbrcId;
		
		this.setSeted(F.tbrcId);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************会员**********************************/	
	/**
	* 会员       
	**/
	public Long getTbrcMember(){
		
		if(this.tbrcMember!=null){
			return this.tbrcMember;
		}
		
		return this.tbrcMember;
	}
	/**
	* 获取会员格式化(toString)
	**/
	public String getTbrcMember$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getTbrcMember());
	 
	 	 return strValue;
	}
	/**
	* 根据会员反格式化
	**/
	public void setTbrcMember$(String strValue){
		if(Utils.empty(strValue)){
			this.tbrcMember=null;
			return;
		}
	
	
	 	this.tbrcMember=Utils.parseLong(strValue);
	 
	}
	
	/**
	* 会员       
	**/
	public void setTbrcMember(Long tbrcMember){
		this.tbrcMember = tbrcMember;
		
		this.setSeted(F.tbrcMember);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************邀请人**********************************/	
	/**
	* 邀请人       
	**/
	public Long getTbrcYq(){
		
		if(this.tbrcYq!=null){
			return this.tbrcYq;
		}
		
		return this.tbrcYq;
	}
	/**
	* 获取邀请人格式化(toString)
	**/
	public String getTbrcYq$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getTbrcYq());
	 
	 	 return strValue;
	}
	/**
	* 根据邀请人反格式化
	**/
	public void setTbrcYq$(String strValue){
		if(Utils.empty(strValue)){
			this.tbrcYq=null;
			return;
		}
	
	
	 	this.tbrcYq=Utils.parseLong(strValue);
	 
	}
	
	/**
	* 邀请人       
	**/
	public void setTbrcYq(Long tbrcYq){
		this.tbrcYq = tbrcYq;
		
		this.setSeted(F.tbrcYq);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************品牌**********************************/	
	/**
	* 品牌       
	**/
	public Long getTbrcBrand(){
		
		if(this.tbrcBrand!=null){
			return this.tbrcBrand;
		}
		
		return this.tbrcBrand;
	}
	/**
	* 获取品牌格式化(toString)
	**/
	public String getTbrcBrand$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getTbrcBrand());
	 
	 	 return strValue;
	}
	/**
	* 根据品牌反格式化
	**/
	public void setTbrcBrand$(String strValue){
		if(Utils.empty(strValue)){
			this.tbrcBrand=null;
			return;
		}
	
	
	 	this.tbrcBrand=Utils.parseLong(strValue);
	 
	}
	
	/**
	* 品牌       
	**/
	public void setTbrcBrand(Long tbrcBrand){
		this.tbrcBrand = tbrcBrand;
		
		this.setSeted(F.tbrcBrand);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************优惠券**********************************/	
	/**
	* 优惠券       
	**/
	public Long getTbrcCoupon(){
		
		if(this.tbrcCoupon!=null){
			return this.tbrcCoupon;
		}
		
		return this.tbrcCoupon;
	}
	/**
	* 获取优惠券格式化(toString)
	**/
	public String getTbrcCoupon$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getTbrcCoupon());
	 
	 	 return strValue;
	}
	/**
	* 根据优惠券反格式化
	**/
	public void setTbrcCoupon$(String strValue){
		if(Utils.empty(strValue)){
			this.tbrcCoupon=null;
			return;
		}
	
	
	 	this.tbrcCoupon=Utils.parseLong(strValue);
	 
	}
	
	/**
	* 优惠券       
	**/
	public void setTbrcCoupon(Long tbrcCoupon){
		this.tbrcCoupon = tbrcCoupon;
		
		this.setSeted(F.tbrcCoupon);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************领取情况**********************************/	
	/**
	* 领取情况    1:未领取 2:已领取    
	**/
	public Short getTbrcGet(){
		
		if(this.tbrcGet!=null){
			return this.tbrcGet;
		}
		
		return this.tbrcGet;
	}
	/**
	* 获取领取情况格式化(toString)
	**/
	public String getTbrcGet$(){
		String strValue="";
	
	
		
			
		 if(Utils.equals(Utils.string(this.getTbrcGet()),"1"))
			strValue=Utils.string("未领取");		 
			
		 if(Utils.equals(Utils.string(this.getTbrcGet()),"2"))
			strValue=Utils.string("已领取");		 
			
		
	 
	 	 return strValue;
	}
	/**
	* 根据领取情况反格式化
	**/
	public void setTbrcGet$(String strValue){
		if(Utils.empty(strValue)){
			this.tbrcGet=null;
			return;
		}
	
	
		
			
		 if(Utils.equals(strValue,"未领取"))
		 	this.tbrcGet=Utils.parseShort("1");
			
		 if(Utils.equals(strValue,"已领取"))
		 	this.tbrcGet=Utils.parseShort("2");
			
		
	 
	}
	
	/**
	* 领取情况    1:未领取 2:已领取    
	**/
	public void setTbrcGet(Short tbrcGet){
		this.tbrcGet = tbrcGet;
		
		this.setSeted(F.tbrcGet);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************添加时间**********************************/	
	/**
	* 添加时间       
	**/
	public Date getTbrcAddTime(){
		
		if(this.tbrcAddTime!=null){
			return this.tbrcAddTime;
		}
		
		return this.tbrcAddTime;
	}
	/**
	* 获取添加时间格式化(toString)
	**/
	public String getTbrcAddTime$(){
		String strValue="";
	
	
	 	
		 strValue=Utils.string(Utils.date(this.getTbrcAddTime(),"yyyy-MM-dd HH:mm:ss"));
		
	 
	 	 return strValue;
	}
	/**
	* 根据添加时间反格式化
	**/
	public void setTbrcAddTime$(String strValue){
		if(Utils.empty(strValue)){
			this.tbrcAddTime=null;
			return;
		}
	
	
	 	this.tbrcAddTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	 
	}
	
	/**
	* 添加时间       
	**/
	public void setTbrcAddTime(Date tbrcAddTime){
		this.tbrcAddTime = tbrcAddTime;
		
		this.setSeted(F.tbrcAddTime);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/	
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(TbReturnCoupon.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(TbReturnCoupon.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(TbReturnCoupon.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(TbReturnCoupon.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(TbReturnCoupon.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${TbReturnCoupon.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${TbReturnCoupon.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return TbReturnCoupon.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(TbReturnCoupon.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${TbReturnCoupon.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${TbReturnCoupon.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return TbReturnCoupon.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(TbReturnCoupon.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		
		
			
		
		/** 编号 [非空]       **/
		public M tbrcId(Object tbrcId){if(proxy)return proxy().tbrcId(tbrcId);  this.put("tbrcId", tbrcId);return this;};
	 	/** and tbrc_id is null */
 		public M tbrcIdNull(){if(proxy)return proxy().tbrcIdNull();if(this.get("tbrcIdNot")==null)this.put("tbrcIdNot", "");this.put("tbrcId", null);return this;};
 		/** not .... */
 		public M tbrcIdNot(){if(proxy)return proxy().tbrcIdNot();this.put("tbrcIdNot", "not");return this;};
 		public M tbrcIdNotNull(){if(proxy)return proxy().tbrcIdNotNull();this.put("tbrcIdNot", "not");this.put("tbrcId", null);return this;};
 		public M tbrcIdNot(Object tbrcId){if(proxy)return proxy().tbrcIdNot(tbrcId);this.put("tbrcIdNot", "not");this.put("tbrcId", tbrcId);return this;};
	 		
		/** and tbrc_id <= ? */
		public M tbrcIdMin(Object min){if(proxy)return proxy().tbrcIdMin(min);this.put("tbrcIdMin", min);return this;};
		/** and tbrc_id >= ? */
		public M tbrcIdMax(Object max){if(proxy)return proxy().tbrcIdMax(max);this.put("tbrcIdMax", max);return this;};
			
			
		public M tbrcIdIn(String ids){
			if(proxy)return proxy().tbrcIdIn(ids);  this.put("tbrcIdIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 会员        **/
		public M tbrcMember(Object tbrcMember){if(proxy)return proxy().tbrcMember(tbrcMember);  this.put("tbrcMember", tbrcMember);return this;};
	 	/** and tbrc_member is null */
 		public M tbrcMemberNull(){if(proxy)return proxy().tbrcMemberNull();if(this.get("tbrcMemberNot")==null)this.put("tbrcMemberNot", "");this.put("tbrcMember", null);return this;};
 		/** not .... */
 		public M tbrcMemberNot(){if(proxy)return proxy().tbrcMemberNot();this.put("tbrcMemberNot", "not");return this;};
 		public M tbrcMemberNotNull(){if(proxy)return proxy().tbrcMemberNotNull();this.put("tbrcMemberNot", "not");this.put("tbrcMember", null);return this;};
 		public M tbrcMemberNot(Object tbrcMember){if(proxy)return proxy().tbrcMemberNot(tbrcMember);this.put("tbrcMemberNot", "not");this.put("tbrcMember", tbrcMember);return this;};
	 		
		/** and tbrc_member <= ? */
		public M tbrcMemberMin(Object min){if(proxy)return proxy().tbrcMemberMin(min);this.put("tbrcMemberMin", min);return this;};
		/** and tbrc_member >= ? */
		public M tbrcMemberMax(Object max){if(proxy)return proxy().tbrcMemberMax(max);this.put("tbrcMemberMax", max);return this;};
			
			
		public M tbrcMemberIn(String ids){
			if(proxy)return proxy().tbrcMemberIn(ids);  this.put("tbrcMemberIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 邀请人        **/
		public M tbrcYq(Object tbrcYq){if(proxy)return proxy().tbrcYq(tbrcYq);  this.put("tbrcYq", tbrcYq);return this;};
	 	/** and tbrc_yq is null */
 		public M tbrcYqNull(){if(proxy)return proxy().tbrcYqNull();if(this.get("tbrcYqNot")==null)this.put("tbrcYqNot", "");this.put("tbrcYq", null);return this;};
 		/** not .... */
 		public M tbrcYqNot(){if(proxy)return proxy().tbrcYqNot();this.put("tbrcYqNot", "not");return this;};
 		public M tbrcYqNotNull(){if(proxy)return proxy().tbrcYqNotNull();this.put("tbrcYqNot", "not");this.put("tbrcYq", null);return this;};
 		public M tbrcYqNot(Object tbrcYq){if(proxy)return proxy().tbrcYqNot(tbrcYq);this.put("tbrcYqNot", "not");this.put("tbrcYq", tbrcYq);return this;};
	 		
		/** and tbrc_yq <= ? */
		public M tbrcYqMin(Object min){if(proxy)return proxy().tbrcYqMin(min);this.put("tbrcYqMin", min);return this;};
		/** and tbrc_yq >= ? */
		public M tbrcYqMax(Object max){if(proxy)return proxy().tbrcYqMax(max);this.put("tbrcYqMax", max);return this;};
			
			
		public M tbrcYqIn(String ids){
			if(proxy)return proxy().tbrcYqIn(ids);  this.put("tbrcYqIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 品牌        **/
		public M tbrcBrand(Object tbrcBrand){if(proxy)return proxy().tbrcBrand(tbrcBrand);  this.put("tbrcBrand", tbrcBrand);return this;};
	 	/** and tbrc_brand is null */
 		public M tbrcBrandNull(){if(proxy)return proxy().tbrcBrandNull();if(this.get("tbrcBrandNot")==null)this.put("tbrcBrandNot", "");this.put("tbrcBrand", null);return this;};
 		/** not .... */
 		public M tbrcBrandNot(){if(proxy)return proxy().tbrcBrandNot();this.put("tbrcBrandNot", "not");return this;};
 		public M tbrcBrandNotNull(){if(proxy)return proxy().tbrcBrandNotNull();this.put("tbrcBrandNot", "not");this.put("tbrcBrand", null);return this;};
 		public M tbrcBrandNot(Object tbrcBrand){if(proxy)return proxy().tbrcBrandNot(tbrcBrand);this.put("tbrcBrandNot", "not");this.put("tbrcBrand", tbrcBrand);return this;};
	 		
		/** and tbrc_brand <= ? */
		public M tbrcBrandMin(Object min){if(proxy)return proxy().tbrcBrandMin(min);this.put("tbrcBrandMin", min);return this;};
		/** and tbrc_brand >= ? */
		public M tbrcBrandMax(Object max){if(proxy)return proxy().tbrcBrandMax(max);this.put("tbrcBrandMax", max);return this;};
			
			
		public M tbrcBrandIn(String ids){
			if(proxy)return proxy().tbrcBrandIn(ids);  this.put("tbrcBrandIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 优惠券        **/
		public M tbrcCoupon(Object tbrcCoupon){if(proxy)return proxy().tbrcCoupon(tbrcCoupon);  this.put("tbrcCoupon", tbrcCoupon);return this;};
	 	/** and tbrc_coupon is null */
 		public M tbrcCouponNull(){if(proxy)return proxy().tbrcCouponNull();if(this.get("tbrcCouponNot")==null)this.put("tbrcCouponNot", "");this.put("tbrcCoupon", null);return this;};
 		/** not .... */
 		public M tbrcCouponNot(){if(proxy)return proxy().tbrcCouponNot();this.put("tbrcCouponNot", "not");return this;};
 		public M tbrcCouponNotNull(){if(proxy)return proxy().tbrcCouponNotNull();this.put("tbrcCouponNot", "not");this.put("tbrcCoupon", null);return this;};
 		public M tbrcCouponNot(Object tbrcCoupon){if(proxy)return proxy().tbrcCouponNot(tbrcCoupon);this.put("tbrcCouponNot", "not");this.put("tbrcCoupon", tbrcCoupon);return this;};
	 		
		/** and tbrc_coupon <= ? */
		public M tbrcCouponMin(Object min){if(proxy)return proxy().tbrcCouponMin(min);this.put("tbrcCouponMin", min);return this;};
		/** and tbrc_coupon >= ? */
		public M tbrcCouponMax(Object max){if(proxy)return proxy().tbrcCouponMax(max);this.put("tbrcCouponMax", max);return this;};
			
			
		public M tbrcCouponIn(String ids){
			if(proxy)return proxy().tbrcCouponIn(ids);  this.put("tbrcCouponIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 领取情况    1:未领取 2:已领取     **/
		public M tbrcGet(Object tbrcGet){if(proxy)return proxy().tbrcGet(tbrcGet);  this.put("tbrcGet", tbrcGet);return this;};
	 	/** and tbrc_get is null */
 		public M tbrcGetNull(){if(proxy)return proxy().tbrcGetNull();if(this.get("tbrcGetNot")==null)this.put("tbrcGetNot", "");this.put("tbrcGet", null);return this;};
 		/** not .... */
 		public M tbrcGetNot(){if(proxy)return proxy().tbrcGetNot();this.put("tbrcGetNot", "not");return this;};
 		public M tbrcGetNotNull(){if(proxy)return proxy().tbrcGetNotNull();this.put("tbrcGetNot", "not");this.put("tbrcGet", null);return this;};
 		public M tbrcGetNot(Object tbrcGet){if(proxy)return proxy().tbrcGetNot(tbrcGet);this.put("tbrcGetNot", "not");this.put("tbrcGet", tbrcGet);return this;};
	 		
			
		public M tbrcGetIn(String ids){
			if(proxy)return proxy().tbrcGetIn(ids);  this.put("tbrcGetIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 添加时间        **/
		public M tbrcAddTime(Object tbrcAddTime){if(proxy)return proxy().tbrcAddTime(tbrcAddTime);  this.put("tbrcAddTime", tbrcAddTime);return this;};
	 	/** and tbrc_add_time is null */
 		public M tbrcAddTimeNull(){if(proxy)return proxy().tbrcAddTimeNull();if(this.get("tbrcAddTimeNot")==null)this.put("tbrcAddTimeNot", "");this.put("tbrcAddTime", null);return this;};
 		/** not .... */
 		public M tbrcAddTimeNot(){if(proxy)return proxy().tbrcAddTimeNot();this.put("tbrcAddTimeNot", "not");return this;};
 		public M tbrcAddTimeNotNull(){if(proxy)return proxy().tbrcAddTimeNotNull();this.put("tbrcAddTimeNot", "not");this.put("tbrcAddTime", null);return this;};
 		public M tbrcAddTimeNot(Object tbrcAddTime){if(proxy)return proxy().tbrcAddTimeNot(tbrcAddTime);this.put("tbrcAddTimeNot", "not");this.put("tbrcAddTime", tbrcAddTime);return this;};
	 		
 		/** and tbrc_add_time >= ? */
 		public M tbrcAddTimeStart(Object start){if(proxy)return proxy().tbrcAddTimeStart(start);this.put("tbrcAddTimeStart", start);return this;};			
 		/** and tbrc_add_time <= ? */
 		public M tbrcAddTimeEnd(Object end){if(proxy)return proxy().tbrcAddTimeEnd(end);this.put("tbrcAddTimeEnd", end);return this;};
			
			
		
			
	 	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	
	 	/** 获取所有回归优惠券 **/
		public @api List<TbReturnCoupon> list(Integer size){			
			return getTbReturnCouponList(this,size);
		}
		/** 获取回归优惠券分页 **/
		public @api Page<TbReturnCoupon> page(Integer page,Integer size){			
			return getTbReturnCouponPage(page, size , this);
		}
		/** 根据查询条件取回归优惠券 **/
		public @api TbReturnCoupon get(){			
			return getTbReturnCoupon(this);
		}
		/** 获取回归优惠券数 **/
		public @api Long count(){			
			return getTbReturnCouponCount(this);
		}
		/** 获取回归优惠券表达式 **/
		public @api <T> T eval(String strEval){			
			return getTbReturnCouponEval(strEval,this);
		}
		
		/** 获取回归优惠券统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getTbReturnCouponStats(this,sumKey,groupKey,dateType);
		}
		/** 获取回归优惠券统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getTbReturnCouponStats(this,sumKey,groupKey,-1);
		}
		
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateTbReturnCoupon(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteTbReturnCoupon(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		
			
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String tbrcId="tbrcId";
	 			
			
	 	
			
		/** 会员        **/
		public final static @type(Long.class)  String tbrcMember="tbrcMember";
	 			
		/** and tbrc_member >= ? */
		public final static @type(Long.class) String tbrcMemberMin="tbrcMemberMin";
		/** and tbrc_member <= ? */
		public final static @type(Long.class) String tbrcMemberMax="tbrcMemberMax";
				
			
	 	
			
		/** 邀请人        **/
		public final static @type(Long.class)  String tbrcYq="tbrcYq";
	 			
		/** and tbrc_yq >= ? */
		public final static @type(Long.class) String tbrcYqMin="tbrcYqMin";
		/** and tbrc_yq <= ? */
		public final static @type(Long.class) String tbrcYqMax="tbrcYqMax";
				
			
	 	
			
		/** 品牌        **/
		public final static @type(Long.class)  String tbrcBrand="tbrcBrand";
	 			
		/** and tbrc_brand >= ? */
		public final static @type(Long.class) String tbrcBrandMin="tbrcBrandMin";
		/** and tbrc_brand <= ? */
		public final static @type(Long.class) String tbrcBrandMax="tbrcBrandMax";
				
			
	 	
			
		/** 优惠券        **/
		public final static @type(Long.class)  String tbrcCoupon="tbrcCoupon";
	 			
		/** and tbrc_coupon >= ? */
		public final static @type(Long.class) String tbrcCouponMin="tbrcCouponMin";
		/** and tbrc_coupon <= ? */
		public final static @type(Long.class) String tbrcCouponMax="tbrcCouponMax";
				
			
	 	
			
		/** 领取情况    1:未领取 2:已领取     **/
		public final static @type(Short.class)  String tbrcGet="tbrcGet";
	 			
			
	 	
			
		/** 添加时间        **/
		public final static @type(Date.class)  String tbrcAddTime="tbrcAddTime";
	 			
	 	/** and tbrc_add_time >= ? */
 		public final static @type(Date.class) String tbrcAddTimeStart="tbrcAddTimeStart";
 		/** and tbrc_add_time <= ? */
 		public final static @type(Date.class) String tbrcAddTimeEnd="tbrcAddTimeEnd";
				
			
	 	
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/** 对象的数据库字段描述 **/
	public static enum C{
		
		tbrcId("tbrc_id"),
		tbrcMember("tbrc_member"),
		tbrcYq("tbrc_yq"),
		tbrcBrand("tbrc_brand"),
		tbrcCoupon("tbrc_coupon"),
		tbrcGet("tbrc_get"),
		tbrcAddTime("tbrc_add_time"),
		count("count");
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	
	/**
	* 获取回归优惠券数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = TbReturnCoupon.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = TbReturnCoupon.getTbReturnCoupon(params);
			else
				value = TbReturnCoupon.getTbReturnCouponList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  TbReturnCoupon.where().tbrcId(param).get();
		else if(!Utils.empty(param.toString()))
			value = TbReturnCoupon.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		return toJSON(simple,0);
	}
	public Map toJSON(boolean simple,int step){
		Map map = new HashMap();
		map.put("id",this.getTbrcId());
	
		Utils.fms(map,simple?"id":"tbrcId",this.getTbrcId(),this.getTbrcId$());
		
			
 		
	
		Utils.fms(map,simple?"member":"tbrcMember",this.getTbrcMember(),this.getTbrcMember$());
		
			
 		
	
		Utils.fms(map,simple?"yq":"tbrcYq",this.getTbrcYq(),this.getTbrcYq$());
		
			
 		
	
		Utils.fms(map,simple?"brand":"tbrcBrand",this.getTbrcBrand(),this.getTbrcBrand$());
		
			
 		
	
		Utils.fms(map,simple?"coupon":"tbrcCoupon",this.getTbrcCoupon(),this.getTbrcCoupon$());
		
			
 		
	
		Utils.fms(map,simple?"get":"tbrcGet",this.getTbrcGet(),this.getTbrcGet$());
		
			
 		
	
		Utils.fms(map,simple?"addTime":"tbrcAddTime",this.getTbrcAddTime(),this.getTbrcAddTime$());
		
		map.put("atime",this.getTbrcAddTime$());map.put("ctime",this.getTbrcAddTime$());
		
			
 		
	
		if(this.suffix!=null)map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
	
		map.put("tbrcId",this.getTbrcId());
 		
	
		map.put("tbrcMember",this.getTbrcMember());
 		
	
		map.put("tbrcYq",this.getTbrcYq());
 		
	
		map.put("tbrcBrand",this.getTbrcBrand());
 		
	
		map.put("tbrcCoupon",this.getTbrcCoupon());
 		
	
		map.put("tbrcGet",this.getTbrcGet());
 		
	
		map.put("tbrcAddTime",this.getTbrcAddTime());
 		
	
		map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static TbReturnCoupon fromMap(Map map){
		TbReturnCoupon tbReturnCoupon = new TbReturnCoupon();
	
		tbReturnCoupon.tbrcId = Utils.parseLong(map.get("tbrcId"));
 		
	
		tbReturnCoupon.tbrcMember = Utils.parseLong(map.get("tbrcMember"));
 		
	
		tbReturnCoupon.tbrcYq = Utils.parseLong(map.get("tbrcYq"));
 		
	
		tbReturnCoupon.tbrcBrand = Utils.parseLong(map.get("tbrcBrand"));
 		
	
		tbReturnCoupon.tbrcCoupon = Utils.parseLong(map.get("tbrcCoupon"));
 		
	
		tbReturnCoupon.tbrcGet = Utils.parseShort(map.get("tbrcGet"));
 		
	
		tbReturnCoupon.tbrcAddTime = Utils.parseDate(map.get("tbrcAddTime"));
 		
	
		return tbReturnCoupon;
	}
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(TbReturnCoupon old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	
	
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	
	public static String getIcon(){
		return "";
	}
	public static String getIconfont(){
		return "icon-libreoffice";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,TbReturnCoupon.M params){
		if(params==null)params=new TbReturnCoupon.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/coupons/returncoupon.edit.html?";
		if(params.get("tbrcId")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("tbrcId"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/coupons/returncoupon.html?1=1";
		
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		
		
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.tbrcId(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(TbReturnCoupon.ACT act,TbReturnCoupon.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",TbReturnCoupon.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(TbReturnCoupon.ACT act,TbReturnCoupon.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",TbReturnCoupon.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.ITbReturnCouponDao getTbReturnCouponDao(){
		return Utils.getBean("tbReturnCouponDao");
	};
	
}